<?php include "../public/header.php"?>
<?php include "../public/header_public.php"?>
<body class="laytp-container">
<div style="height: 45px"></div>
<div id="opt_nav">
</div>
<div id="dialog">
    <div class="page-title" id="page-title">
        <div class="page-title-con">
            <span class="title">选择工程-销售方信息</span>
            <div class="move_title"></div>
            <div class="page-title-opt-list">
                <button class="layui-btn layui-btn-sm btn-dark marginr5" type="button" id="submit">确定</button>
                <span id="page-close" class="page-close" onclick="layer_close()">×</span>
            </div>
        </div>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="toolbarDemo">

</script>
<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
    </div>
</script>
<script type="text/javascript">
    // 单选多选分类 默认单选 choose_type传值为多选
    var choose_type = getQueryVariable('choose_type');
    if(choose_type === undefined || choose_type === false){
        choose_type = 'radio';
    }else{
        choose_type = 'checkbox';
    }

    var parent_dom = getQueryVariable('dom');
    var parent_enginid = getQueryVariable('enginid') || 0;
    var parent_domkey = getQueryVariable('domkey');
    var parent_page = getQueryVariable('page');




    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;

        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        $("#cols_table").hide();
        $("#export_table").hide();
        table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_opt_get_engin_gong_tai),where: {enginid:parent_enginid}, page: false, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: ['', '', ''],filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,parseData: function(res){

                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.total,
                    "data": res.data.data
                };
            }
            ,cols: [[
                {type:choose_type,fixed:'left'}
                ,{type:'numbers',title:'序号',fixed:'left'}
                ,{field:'enginname',title:'工程名称'}
                ,{field:'gonger',title:'销售方名称'}
                ,{field:'hougongzhifee',title:'累计支付销售方(元)'}
                ,{field:'piaoshoufee',title:'销售方进项票累计(元)'}
                ,{field:'keqiancai',title:'销售方可签采购合同金额(元)'}
                ,{field:'yiqiancai',title:'销售方已签采购合同金额(元)'}
                ,{field:'daiqiancai',title:'销售方待签采购合同金额(元)'}
                ,{field:'kedijin',title:'可抵扣进项票金额(元)'}
                ,{field:'yidijin',title:'已抵扣进项票价税合计(元)'}
                ,{field:'yidirate',title:'已抵扣退税(元)'}
                ,{field:'shengdijin',title:'剩余可抵扣进项票金额(元)'}
            ]]
            ,done : function(res, curr, count){
                // $(".layui-table-tool").remove()
                soulTable.render(this);
            }
        });
        listTableSearch(form, table);


        $('#submit').on('click', function () {
            var checkStatus = layui.table.checkStatus('datalist');
            var data = checkStatus.data;
            if(data.length < 1){
                facade.error("请选择数据");return false;
            }

            if(parent_page == '页面值'){

            }else if(parent_page == 'hou_gongshui_list'){
                var nums = $("#list_list tr", parent.document).length;
                for (var key in data){
                    var str = '';
                    nums++;

                    data[key].hougongzhifee = data[key].hougongzhifee || 0;
                    data[key].piaoshoufee = data[key].piaoshoufee || 0;
                    data[key].yiqiancai = data[key].yiqiancai || 0;
                    data[key].kedijin = data[key].kedijin || 0;
                    data[key].yidijin = data[key].yidijin || 0;
                    data[key].yidirate = data[key].yidirate || 0;
                    data[key].shengdijin = data[key].shengdijin || 0;

                    str += '<tr>';
                    str += '<td style="width: 45px">'+nums+'</td>';
                    str += '<td><input type="text"  value="'+data[key].gonger+'" readonly class="layui-input xiaoer disabled"></td>';
                    str += '<td><input type="text" value="'+data[key].hougongzhifee+'" class="layui-input disabled gongzhifee" disabled></td>';
                    str += '<td><input type="text" value="'+data[key].piaoshoufee+'" class="layui-input disabled piaoshoufee" disabled></td>';
                    str += '<td><input type="text" value="'+data[key].yiqiancai+'" class="layui-input disabled concaimoney" disabled></td>';
                    str += '<td><input type="text" value="'+data[key].kedijin+'" class="layui-input disabled kedifee" disabled></td>';
                    str += '<td><input type="text" value="'+data[key].yidijin+'" class="layui-input disabled yidimoney" disabled></td>';
                    str += '<td><input type="text" value="'+data[key].yidirate+'" class="layui-input disabled yidiratefee" disabled></td>';
                    str += '<td><input type="text" value="'+data[key].shengdijin+'" class="layui-input disabled shengdifee" disabled></td>';
                    str += '<td><input type="text" onclick="choose_piao_shou_guan(this)" readonly class="layui-input money disabled"><span class="difeeobj layui-hide"></span></td>';
                    str += '<td><input type="text" class="layui-input disabled ratefee" disabled></td>';
                    str += '<td><input type="text" class="layui-input explain"></td>';
                    str += '</tr>';
                    $("#list_list", parent.document).append(str);
                    parent.xmselect_list_dan('incdaotype'+nums, parent.pub_incdaotype, '');
                }

                if (typeof(window.parent.update_refresh_row_func)!="undefined"){
                    window.parent.update_refresh_row_func();
                }
            }else{

            }

            layer_close();
        });




    });



    function auth_but_func_add_flow(){
        openPageEdit('../dealcom/flow_add.php?close=1');
    }
    function auth_but_func_show(id){
        openPage('../dealcom/show.php?id='+id);
    }
    function auth_but_func_edit(id){
        openPageEdit('../dealcom/edit.php?close=1&id='+id);
    }
</script>
</body>
</html>
